From: Rui Matos Date: Thu, 26 Feb 2015 18:21:52 +0000 (+0100) Subject: viewSelector: Don't reset the search entry if it has preedit text X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1573 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b58f08bda1b854b944043bb22a2358f1277904d6;p=gnome-shell.git viewSelector: Don't reset the search entry if it has preedit text If users click outside the search entry while it's empty we reset and thus give up key focus. This means that when using an input method with candidate popups, interacting with the popup with a mouse click cancels the current input method context if there's no other text in the entry besides the preedit string. To avoid this we can check if the entry has preedit in addition to checking if it has normal text. https://bugzilla.gnome.org/show_bug.cgi?id=745167 --- diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index ab22ff928..6856f1865 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -552,7 +552,9 @@ const ViewSelector = new Lang.Class({ _onCapturedEvent: function(actor, event) { if (event.type() == Clutter.EventType.BUTTON_PRESS) { let source = event.get_source(); - if (source != this._text && this._text.text == '' && + if (source != this._text && + this._text.text == '' && + !this._text.has_preedit () && !Main.layoutManager.keyboardBox.contains(source)) { // the user clicked outside after activating the entry, but // with no search term entered and no keyboard button pressed diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c index 5666e7acd..12b7e3fe4 100644 --- a/src/st/st-im-text.c +++ b/src/st/st-im-text.c @@ -67,6 +67,7 @@ struct _StIMTextPrivate GdkWindow *window; guint need_im_reset : 1; + guint has_preedit : 1; }; G_DEFINE_TYPE (StIMText, st_im_text, CLUTTER_TYPE_TEXT) @@ -136,6 +137,8 @@ st_im_text_preedit_changed_cb (GtkIMContext *context, preedit_attrs, cursor_pos); + imtext->priv->has_preedit = preedit_str && *preedit_str; + g_free (preedit_str); pango_attr_list_unref (preedit_attrs); } @@ -622,3 +625,17 @@ st_im_text_get_input_hints (StIMText *imtext) return hints; } + +/** + * st_im_text_has_preedit: + * @imtext: a #StIMText + * + * Returns: wether @imtext currently has preedit text + */ +gboolean +st_im_text_has_preedit (StIMText *imtext) +{ + g_return_val_if_fail (ST_IS_IM_TEXT (imtext), FALSE); + + return imtext->priv->has_preedit; +} diff --git a/src/st/st-im-text.h b/src/st/st-im-text.h index c97975ae9..4c96248b8 100644 --- a/src/st/st-im-text.h +++ b/src/st/st-im-text.h @@ -67,6 +67,7 @@ GtkInputPurpose st_im_text_get_input_purpose (StIMText *imtext); void st_im_text_set_input_hints (StIMText *imtext, GtkInputHints hints); GtkInputHints st_im_text_get_input_hints (StIMText *imtext); +gboolean st_im_text_has_preedit (StIMText *imtext); void st_im_text_set_event_window (GdkWindow *window);